<?php
$this->pageTitle=Yii::app()->name . ' - Bomb';
?>

<script type="text/javascript">
var _timeStamp=1329929385;
var siteurl="<?php echo Yii::app()->request->baseUrl;?>/index.php/game/";
</script>

<div>
	<div class='box'>
		<h2 style="color: #449944;" class="text1">Đặt bomb ăn tiền</h2>

		<?php if(isset($rule)){echo $rule['value'];}?>
	</div>
	<div id="tabs"
		class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<ul
			class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
			<li
				class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a
				href="#tabs-1">Đặt bomb</a></li>
			<li class="ui-state-default ui-corner-top"><a href="#tabs-2">Bomb của
					tôi</a></li>
			<li class="ui-state-default ui-corner-top"><a href="#tabs-3">Bomb tôi
					gỡ</a></li>
			<li class="ui-state-default ui-corner-top"><a href="#tabs-4">Danh
					sách bomb</a>
			</li>
		</ul>
		<div id="tabs-1"
			class="ui-tabs-panel ui-widget-content ui-corner-bottom">
			<div style="text-align: left;">




			<?php
			if(isset($error))
			{
				echo '<h3 style="color:red;font-weight:bold;">' . $error . '</h3>';
			}
			if(isset($success))
			{
				echo '<h3 style="color:blue;font-weight:bold;">' . $success . '</h3>';
			}
			?>
				<form method="post" action="bomb">
					<table>
						<tbody>
							<tr>
								<td align="left" width="170" valign="top"><img height="130px"
									alt="bomb"
									src="<?php echo Yii::app()->request->baseUrl; ?>/images/bomb.jpg">
								</td>
								<td width="150" valign="middle"
									style="padding-top: 30px; padding-left: 30px;">Số tiền: <input
									class='text-input' type="text" name="bet_money" size="5"> <br>
									<input class='text-input' type="radio" value="dayxanh"
									name="day"><font color="#0000ff">Dây xanh </font><br> <input
									type="radio" value="daydo" name="day"><font color="#ff0000">Dây
										đỏ</font>
								</td>
								<td style="padding-top: 50px;"><input name='makebomb'
									type="submit" class='button active' value="Đặt bomb">
								</td>
							</tr>
						</tbody>
					</table>
				</form>
			</div>
		</div>
		<div id="tabs-2"
			class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
			<div>
				<table width="100%" border="1" cellpadding="4" cellspacing="4">
					<tr style="color: blue">
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>STT</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Dây
								màu</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tình
								trạng</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Ngày
								tạo</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tiền</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Phá
								bởi</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Nhận
								được</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Hủy</strong>
						</td>
					</tr>
					
					
					
					
					
					<?php $i = 1; ?>
					
					<?php foreach($mybomb as $b):?>
					<tr>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $i; $i+=1;?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $b['string_color'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php if($b['status']==0){echo 'Đang mở';}else{if($b['status']==2){echo 'Hủy';}else{echo 'Đóng';}}?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $b['date_start'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $b['money'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $b['user_name'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php if($b['user_name']!=''){ if($b['choosen']==$b['string_color']){echo '+' . $b['money'] . '$';}else{echo '-' . $b['money'] . '$';} }?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php if($b['status']==0):?><a href='<?php echo Yii::app()->request->baseUrl; ?>/index.php/game/bomb?huy=yes&id=<?php echo $b['id'];?>'>Hủy</a><?php endif;?></td>
					</tr>
					<?php endforeach;?>
				</table>
			</div>
		</div>
		<div id="tabs-3"
			class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
			<div>
				<table width="100%" border="1" cellpadding="4" cellspacing="4">
					<tr style="color: blue">
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>id</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tạo
								bởi</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Dây
								màu</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tình
								trạng</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Ngày
								tạo</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tiền</strong>
						</td>
						<td style="border: thin solid white" bgcolor="#DADADA"><strong>Nhận
								được</strong>
						</td>
					</tr>
					
					
					
					
					
					<?php foreach($mybomb_remove as $br):?>
					<tr>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $br['id'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $br['user_name'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $br['string_color'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php if($br['status']==0){echo 'Đang mở';}else{echo 'Đóng';}?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $br['date_start'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $br['money'];?>$</td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php if($br['choosen']==$br['string_color']){

                            $realmoney = 0;
                            if($br['money']>=0.5 && $br['money']<1.9)
                            {
                                $realmoney = ($br['money']-0.05);
                            }
                            if($br['money']>=2 && $br['money']<5)
                            {
                                $realmoney = ($br['money']-0.1);
                            }
                            if($br['money']>=5 && $br['money']<10)
                            {
                                $realmoney = (($br['money']*90)/100);
                            }


                            echo '+' . $realmoney;}else{echo '-' . $br['money'];}?></td>
					</tr>
					<?php endforeach;?>
				</table>
			</div>
		</div>
		<div id="tabs-4"
			class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
			<div>
				<div>
				<div id='remove_bomb_info'></div>
					<table width="100%" border="1" cellpadding="4" cellspacing="4">
						<tr style="color: blue">
							<td style="border: thin solid white" bgcolor="#DADADA"><strong>id</strong>
							</td>
							<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tạo
									bởi</strong>
							</td>
							<td style="border: thin solid white" bgcolor="#DADADA"><strong>Ngày
									tạo</strong>
							</td>
							<td style="border: thin solid white" bgcolor="#DADADA"><strong>Tiền</strong>
							</td>
							<td style="border: thin solid white" bgcolor="#DADADA"><strong>Hành
									động</strong>
							</td>
						</tr>
						
						
						
						
					
					<?php foreach($allbomb as $ab):?>
					<tr>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $ab['id'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $ab['user_name'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $ab['date_start'];?></td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><?php echo $ab['money'];?>$</td>
						<td style="border: thin solid white" bgcolor="#F8F8F8"><a href="javascript:removeBomb('dayxanh',<?php echo $ab['id'];?>)"><img border="0" src="https://www.cakiem.com/images/bt_catxanh.jpg"></a><a href="javascript:removeBomb('daydo',<?php echo $ab['id'];?>)"><img border="0" src="https://www.cakiem.com/images/bt_catdo.jpg"></a></td>
					</tr>
					<?php endforeach;?>
				</table>
				</div>
			</div>
		</div>
	</div>
	<style type="text/css">
<!--
div.scroll {
	height: 250px;
	width: 640px;
	overflow: auto;
	border: 1px solid #666;
	background-color: #ccc;
	padding: 8px;
}
-->
</style>
	<div class='box'>
		<br />
		<h4>
			<marquee direction="left" behavior="scroll">Event Vua gỡ bomb bắt đầu
				từ 20h hàng ngày và kết thúc 8h ngày hôm sau, mọi lợi nhuận sẽ được
				chia cho những ai đứng top ở 3 bảng dưới, cụ thể Top 1 đặt bomb nhận
				30%, top 2 đặt bomb là 10% Top 1 gỡ bomb nhận 40% , top 2 gỡ bomb
				nhận 10%, top cảm tử quân 10%. </marquee>
		</h4>
		<h3>
			<font color="red">Lưu ý: Mọi hành vi spam không lành mạnh tại <b>Chatbox</b>
				chúng tôi sẽ block account mà không báo trước
			</font>
		</h3>
		<h2>
			<font color="blue">Tổng lợi nhuận của event đang là: $0</font>
		</h2>
	</div>
	<div class="content-box-header">
		<h3 style="cursor: s-resize;">Chat Logs</h3>
	</div>
	<div id="chatbox" class="list_terms_inner"
		style="height: 250px; width: 98%;">




		<?php echo $html_chat;?>
	</div>
	<br />
	<form action="">
		<input type="text" style="width: 595px;" class=text-input
			onkeypress="{if (event.keyCode==13)sendchat()}" id="chat" name="chat">
		<input type="button" class='button active' style="width: 80px;"
			value="Chat" onclick="sendchat();">
	</form>
	<script>
					function sendchat(){
						
						txtx=$('#chat').val();
						$('#chat').val("");
						$.post('chat',{act:'send',txt:txtx}, function(data) {
							if (data=='login'){
								alert("Đăng nhập để chat");
							} else{									
								$.post('chat',{act:'chataction', txt:txtx}, function(data) {
									$('#chatbox').html(data);
								});
							}
						});
						
					}
					/*	$(document).ready(function() {
							$.post('chat',{act:''}, function(data) {
								$('#chatbox').html(data);
							});					
							setInterval(function() {
								$.post('chat',{act:''}, function(data) {
									$('#chatbox').html(data);
								});
							}, 5000);
										
						});
						*/
					</script>
	<br />
	<div class="content-box-header">
		<h3 style="cursor: s-resize;">Play Logs</h3>
	</div>
	<div class="list_terms_inner" style="height: 250px; width: 98%">
			<?php foreach($play_logs as $pl):?>
				<?php if($pl['status']==1): ?>
					<img align="absmiddle" style="padding: 0px; margin: 0px; float: none;"
					src="<?php echo Yii::app()->request->baseUrl; ?>/images/win.gif">
				<?php endif; ?>
				<?php if($pl['status']==0): ?>
					<img align="absmiddle" style="padding: 0px; margin: 0px; float: none;"
					src="<?php echo Yii::app()->request->baseUrl; ?>/images/loss.gif">
				<?php endif; ?>
				<?php echo $pl['content']; ?><br/>
			<?php endforeach;?>
	</div>
	<br clear="all">
</div>
